#pragma once

#include <iostream>
#include <assert.h>
using namespace std;

namespace lin
{
	class string
	{
	public:
		typedef char* iterator;
		typedef const char* const_iterator;

		string(const char* str = "");
		~string();
		string (const string& s);
		string& operator=(const string& s);

		const char* c_str() const;
		iterator begin();
		iterator end();
		const_iterator begin() const;
		const_iterator end() const;

		size_t size() const;
		char& operator[] (size_t pos);
		const char& operator[] (size_t pos) const;

		void resever(size_t n = 0);

		void push_back(char ch);
		void append(const char* str);
		void insert(size_t pos,char ch);
		void insert(size_t pos,const char* str);
		void erase(size_t pos = 0, size_t len = npos);

		size_t find(char ch,size_t pos = 0);
		size_t find(const char* sub,size_t pos = 0);
		
		void swap(string& s);

		string& operator+=(char ch);
		string& operator+=(const char* str);	
		string substr(size_t pos = 0,size_t len = npos);

		bool operator<(string& s) const;
		bool operator<=(string& s) const;
		bool operator>(string& s) const;
		bool operator>=(string& s) const;
		bool operator==(string& s) const;
		bool operator!=(string& s) const;

		void clear();

	private:
		char* _str;
		size_t _size;
		size_t _capacity;

		const static size_t npos;
	};

	istream& operator>>(istream& is, string& s);
	ostream& operator<<(ostream& os, const string& s);
}